package com.haieros.www.purerunshowsystem.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import com.haieros.www.purerunshowsystem.utils.VideoViewUtil;

import java.util.List;

/**
 * Created by Administrator on 2017/11/18 0018.
 */

public class MyPagerAdapter extends PagerAdapter{

    public List<VideoViewUtil> mVideo;

    public MyPagerAdapter(List<VideoViewUtil> views){
        this.mVideo = views;
    }
    @Override
    public int getCount() {
        return Integer.MAX_VALUE;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }
    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(mVideo.get(position%mVideo.size()));
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(mVideo.get(position%mVideo.size()));
        mVideo.get(position%mVideo.size()).start();
        return mVideo.get(position%mVideo.size());
    }
}
